<?php
/**
 * Created by 
 * User: 单页控制器
 * Date: 2019/04/27
 * Time: 0:21
 */
namespace app\index\controller;

use think\Controller;
use think\Request;

class Page extends Common
{   
    public function _initialize(){
        parent::_initialize();
        $works=$this->getZuopin();
        $about=$this->getchild(16);
        $this->assign([
            'works' =>$works,
            'child' =>$about,
        ]);
    }
    /**
     * 显示单页内容
     *
     * @return \think\Response
     */
    public function index($id)
    {
        $page=db('category')->where('id',$id)->find();
        
        if (!$page) {
            abort(404, '访问的页面不存在');
        }
        $pos=$this->getPos($id);
        $this->assign(array(
            'page'  =>$page,
            'currid'=>$id,//当前栏目id
            'pos'   =>$pos,
        ));
        return view();
    }

    /**
     * 摄影作品
     *
     * @return \think\Response
     */
    public function getZuopin()
    {
        $cate=db('category')->where('pid',20)->field('id,cate_name,type')->select();
        return $cate;
    }

    /**
     * 专业团队
     *
     * @param  \think\Request  $request
     * @return \think\Response
     */
    public function team($id)
    {   
        $team=db('article')->alias('a')
               ->join('pic p','p.aid=a.id')
               ->field('a.id,a.title,a.zhiwu,a.zhicheng,p.pic')
               ->where('a.cid',$id)
               ->paginate(1);
               $cid=db('article')->field('cid')->find();
               $catename=db('category')->where('id',$cid['cid'])->field('cate_name,desc,keyword')->find();
        $pos=$this->getPos($id);
        $this->assign(array(
            'team'  =>$team,
            'currid'=>$id,
            'pos'   =>$pos,
            'catename'=>$catename,
        ));
        return view();
    }
    /**
     * 专业团队详情
     *
     * @param  \think\Request  $request
     * @return \think\Response
     */
    public function teamshow($id){
        $art=db('article')->field('cid,title,keyword,desc,content')->find($id);
        $pos=$this->getPos($art['cid']);
        $this->assign([
            'art' =>$art,
            'currid'=>$art['cid'],
            'pos'   =>$pos,
        ]);
        return view();
    }

    
}
